<?php
/**
 * Albireo Kernel
 *
 * @copyright  Copyright (c) 2010 Albireo Solutions
 * @package    Webtop
 */

namespace WebtopModule\DesktopModule;

use Nette\Object;
use Nette\Collections\ArrayList;

/**
 * Desktop entity
 *
 * @author Albireo Solutions
 */

class Desktop extends Object {
    /** @var int */
    private $id = 0;
    /** @var int */
    private $user;
    /** @var arrayList */
    private $windows = null;
    /** @var arrayList */
    private $icons = null;
    /** @var arrayList */
    private $quickLaunches = null;
    /** @var arrayList */
    private $startMenus = null;
    /** @var int */
    private $skin = null;
    /** @var String */
    private $color = null;
    /** @var File */
    private $backgroundImage = null;
    /** @var int */
    private $panelPosition = null;
    /** @var int */
    private $panelSize = null;
    /** @var bool */
    private $backgroundImageStyle;

    /**
     * constructor
     */
    function __construct() {
	$this->windows = new ArrayList();
	$this->icons = new ArrayList();
	$this->quickLaunches = new ArrayList();
	$this->startMenus = new ArrayList();
    }

    /**
     * id getter
     *
     * @return int id
     */
    public function getId() {
	return $this->id;
    }

    /**
     * id setter
     *
     * @param int id
     */
    public function setId($id) {
	$this->id = $id;
    }

    /**
     * user getter
     *
     * @return int user
     */
    public function getUser() {
	return $this->user;
    }

    /**
     * user setter
     *
     * @param int user
     */
    public function setUser($user) {
	$this->user = $user;
    }

    /**
     * windows getter
     *
     * @return Arraylist windows
     */
    public function getWindows() {
	return $this->windows;
    }

    /**
     * windows setter
     *
     * @param Arraylist windows
     */
    public function setWindows(Arraylist $windows) {
	$this->windows = $windows;
    }

    /**
     * window adder
     *
     * @param Window window
     */
    public function addWindow(Window $window) {
	$this->windows->offsetSet($this->windows->count(), $window);
    }

    /**
     * window updater
     *
     * @param Window window
     */
    public function updateWindow(Window $window) {
	$iterator = $this->windows->getIterator();
	$iterator->rewind();
	while($iterator->valid()) {
	    if($iterator->current()->getId() == $window->getId()) {
		$this->windows->offsetSet($iterator->key(), $window);
		break;
	    }
	    $iterator->next();
	}
	
	// exception ??
    }

    /**
     * window remover
     *
     * @param Window window
     */
    public function removeWindow($window) {
	$iterator = $this->windows->getIterator();
	$iterator->rewind();
	while($iterator->valid()) {
	    if($iterator->current->getId() == $window->getId()) {
		$this->windows->offsetUnset($iterator->key());
		break;
	    }
	}
	// exception ??
    }

    /**
     * window getter
     *
     * @param int id
     * @return Window window
     */
    public function getWindow($id) {
	$iterator = $this->windows->getIterator();
	$iterator->rewind();
	while($iterator->valid()) {
	    if($iterator->current->getId() == $id) {
		return $iterator->current();
	    }
	}
	// exception / return null ??
    }

    /**
     * icons getter
     *
     * @return Arraylist icons
     */
    public function getIcons() {
	return $this->icons;
    }

    /**
     * icons setter
     *
     * @param Arraylist icon
     */
    public function setIcons(Arraylist $icons) {
	$this->icons = $icons;
    }

    /**
     * icon adder
     *
     * @param Icon icon
     */
    public function addIcon(Icon $icon) {
	$this->icons->offsetSet($this->icons->count(), $icon);
    }

    /**
     * icon updater
     *
     * @param Icon icon
     */
    public function updateIcon(Icon $icon) {
	$iterator = $this->icons->getIterator();
	$iterator->rewind();
	while($iterator->valid()) {
	    if($iterator->current()->getId() == $icon->getId()) {
		$this->icons->offsetSet($iterator->key(), $icon);
		break;
	    }
	    $iterator->next();
	}
	// exception ??
    }

    /**
     * icon remover
     *
     * @param Icon icon
     */
    public function removeIcon($icon) {
	$iterator = $this->icons->getIterator();
	$iterator->rewind();
	while($iterator->valid()) {
	    if($iterator->current->getId() == $icon->getId()) {
		$this->icons->offsetUnset($iterator->key());
		break;
	    }
	}
	// exception ??
    }

    /**
     * icon getter
     *
     * @param int id
     * @return Icon icon
     */
    public function getIcon($id) {
	$iterator = $this->icons->getIterator();
	$iterator->rewind();
	while($iterator->valid()) {
	    if($iterator->current->getId() == $id) {
		return $iterator->current();
	    }
	}
	// exception / return null ??
    }

    /**
     * quickLaunches getter
     *
     * @return Arraylist quickLaunches
     */
    public function getQuickLaunches() {
	return $this->quickLaunches;
    }

    /**
     * quickLaunches setter
     *
     * @param Arraylist quickLaunches
     */
    public function setQuickLaunches(ArrayList $quickLaunches) {
	$this->quickLaunches = $quickLaunches;
    }

    /**
     * quickLaunch adder
     *
     * @param QuickLaunch quickLaunch
     */
    public function addQuickLaunch(QuickLaunch $quickLaunch) {
	$this->quickLaunches->offsetSet($this->quickLaunches->count(), $quickLaunch);
    }

    /**
     * quickLaunch updater
     *
     * @param QuickLaunch quickLaunch
     */
    public function updateQuickLaunch(QuickLaunch $quickLaunch) {
	$iterator = $this->quickLaunches->getIterator();
	$iterator->rewind();
	while($iterator->valid()) {
	    if($iterator->current()->getId() == $quickLaunch->getId()) {
		$this->quickLaunches->offsetSet($iterator->key(), $quickLaunch);
		break;
	    }
	    $iterator->next();
	}
	// exception ??
    }

    /**
     * quickLaunch remover
     *
     * @param QuickLaunch quickLaunch
     */
    public function removeQuickLaunch($quickLaunch) {
	$iterator = $this->quickLaunches->getIterator();
	$iterator->rewind();
	while($iterator->valid()) {
	    if($iterator->current->getId() == $quickLaunch->getId()) {
		$this->quickLaunches->offsetUnset($iterator->key());
		break;
	    }
	}
	// exception ??
    }

    /**
     * quickLaunch getter
     *
     * @param int id
     * @return QuickLaunch quickLaunch
     */
    public function getQuickLaunch($id) {
	$iterator = $this->quickLaunches->getIterator();
	$iterator->rewind();
	while($iterator->valid()) {
	    if($iterator->current->getId() == $id) {
		return $iterator->current();
	    }
	}
	// exception / return null ??
    }

    /**
     * startMenus getter
     *
     * @return Arraylist startMenus
     */
    public function getStartMenus() {
	return $this->startMenus;
    }

    /**
     * startMenus setter
     *
     * @param Arraylist startMenu
     */
    public function setStartMenus(Arraylist $startMenus) {
	$this->startMenus = $startMenus;
    }

    /**
     * startMenu adder
     *
     * @param StartMenu startMenu
     */
    public function addStartMenu(StartMenu $startMenu) {
	$this->startMenus->offsetSet($this->startMenus->count(), $startMenu);
    }

    /**
     * startMenu updater
     *
     * @param StartMenu startMenu
     */
    public function updateStartMenu(StartMenu $startMenu) {
	$iterator = $this->startMenus->getIterator();
	$iterator->rewind();
	while($iterator->valid()) {
	    if($iterator->current()->getId() == $startMenu->getId()) {
		$this->startMenus->offsetSet($iterator->key(), $startMenu);
		break;
	    }
	    $iterator->next();
	}
	// exception ??
    }

    /**
     * startMenu remover
     *
     * @param StartMenu startMenu
     */
    public function removeStartMenu($startMenu) {
	$iterator = $this->startMenus->getIterator();
	$iterator->rewind();
	while($iterator->valid()) {
	    if($iterator->current->getId() == $startMenu->getId()) {
		$this->startMenus->offsetUnset($iterator->key());
		break;
	    }
	}
	// exception ??
    }

    /**
     * startMenu getter
     *
     * @param int id
     * @return StartMenu startMenu
     */
    public function getStartMenu($id) {
	$iterator = $this->startMenus->getIterator();
	$iterator->rewind();
	while($iterator->valid()) {
	    if($iterator->current->getId() == $id) {
		return $iterator->current();
	    }
	}
	// exception / return null ??
    }

    /**
     * skin getter
     *
     * @return Skin
     */
    public function getSkin() {
	return $this->skin;
    }

    /**
     * skin setter
     *
     * @return Skin
     */
    public function setSkin($skin) {
	$this->skin = $skin;
    }

    /**
     * color getter
     *
     * @return String
     */
    public function getColor() {
	return $this->color;
    }

    /**
     * color getter
     *
     * @param String
     */
    public function setColor($color) {
	$this->color = $color;
    }

    /**
     * backgroundImage getter
     *
     * @return file
     */
    public function getBackgroundImage() {
	return $this->backgroundImage;
    }

    /**
     * backgroundImage setter
     *
     * @param File
     */
    public function setBackgroundImage($image) {
	$this->backgroundImage = $image;
    }

    /**
     * panelPosition getter
     *
     * @return int
     */
    public function getPanelPosition() {
	return $this->panelPosition;
    }

    /**
     * panelPosition setter
     *
     * @param int
     */
    public function setPanelPosition($position) {
	$this->panelPosition = $position;
    }

    /**
     * panelSize getter
     *
     * @return int
     */
    public function getPanelSize() {
	return $this->panelSize;
    }

    /**
     * panelSize setter
     *
     * @param int
     */
    public function setPanelSize($size) {
	$this->panelSize = $size;
    }

    /**
     * backroundImageStyle getter
     *
     * @return int
     */
    public function getBackgroundImageStyle() {
	return $this->backgroundImageStyle;
    }

    /**
     * backgroundImageStyle setter
     *
     * @param int
     */
    public function setBackgroundImageStyle($imageStyle) {
	$this->backgroundImageStyle = $imageStyle;
    }
}
